from typing_extensions import TypedDict
from langgraph.graph import StateGraph,START,END

def addition(state):
    print(state)
    return {"x":state["x"]+1}

def subtraction(state):
    print(state)
    return  {"x":state["x"]-2}

class State(TypedDict):
    x:int
    y:int

builder = StateGraph(State)

builder.add_node("addition",addition)
builder.add_node("substraction",subtraction)

builder.add_edge(START,"addition")
builder.add_edge("addition","substraction")
builder.add_edge("substraction",END)

graph = builder.compile()

res = graph.invoke({"x":10})
print(res)